package com.gupaoedu.demo.serialize;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * <p>
 *
 * </p>
 *
 * @author Nicky
 * @since 2019-07-20
 */
public class Server {

    public static void main(String[] args) throws IOException {
        ServerSocket  serverSocket = null;
        try {
            serverSocket =new ServerSocket(8080);
            Socket socket = serverSocket.accept();
            ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream());
            User user = (User) objectInputStream.readObject();
            System.out.println(user);
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        finally {
            if(serverSocket != null){
                serverSocket.close();
            }

        }
    }

}
